package cn.gx.kevin.common.utils;

import java.util.HashSet;
import java.util.Set;

/***
 *@description :
 *@author : kevin.huang
 *@date : 2019/11/3 11:48
 @modified by
 ***/
public class MybatisJDBCTypeName {

    public static String jdbcTypeList = "CHAR,VARCHAR,LONGVARCHAR,NUMERIC,DECIMAL,BIT,BOOLEAN,TINYINT,SMALLINT,INTEGER,BIGINT,REAL,FLOAT,DOUBLE,BINARY,VARBINARY,LONGVARBINARY,DATE,TIME,TIMESTAMP,CLOB,BLOB,ARRAY,DISTINCT,STRUCT,REF,DATALINK";

    private static Set<String> jdbcSet = new HashSet<>();
    static {
        String tmp [] =   MybatisJDBCTypeName.jdbcTypeList.split(",");
        for(String s : tmp){
            if(!jdbcSet.contains(s)){
                jdbcSet.add(s);
            }
        }
    }

    /*****
     * 验证输入的类型名称是否合法
     * *****/
    public static String   getLegalTypeName(String typeName){
        if(typeName == null){
            return null;
        }
        String tmp = typeName.toUpperCase();
        if( jdbcSet.contains(tmp)){
            return tmp;
        }
        return null;
    }

    public static String  CHAR_NAME         = "CHAR";
    public static String  VARCHAR_NAME      = "VARCHAR";
    public static String  LONGVARCHAR_NAME  = "LONGVARCHAR";
    public static String  NUMERIC_NAME      = "NUMERIC";
    public static String  DECIMAL_NAME      = "DECIMAL";
    public static String  BIT_NAME          = "BIT";
    public static String  BOOLEAN_NAME      = "BOOLEAN";
    public static String  TINYINT_NAME      = "TINYINT";
    public static String  SMALLINT_NAME     = "SMALLINT";
    public static String  INTEGER_NAME      = "INTEGER";
    public static String  BIGINT_NAME       = "BIGINT";
    public static String  REAL_NAME         = "REAL";
    public static String  FLOAT_NAME        = "FLOAT";
    public static String  DOUBLE_NAME       = "DOUBLE";
    public static String  BINARY_NAME       = "BINARY";
    public static String  VARBINARY_NAME    = "VARBINARY";
    public static String  LONGVARBINARY_NAME= "LONGVARBINARY";
    public static String  DATE_NAME         = "DATE";
    public static String  TIME_NAME         = "TIME";
    public static String  TIMESTAMP_NAME    = "TIMESTAMP";
    public static String  CLOB_NAME         = "CLOB";
    public static String  BLOB_NAME         = "BLOB";
    public static String  ARRAY_NAME        = "ARRAY";
    public static String  DISTINCT_NAME     = "DISTINCT";
    public static String  STRUCT_NAME       = "STRUCT";
    public static String  REF_NAME          = "REF";
    public static String  DATALINK_NAME     = "DATALINK";
}
